package com.jiaai.web.common;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.exception.ServerException;
import com.jiaai.gift.api.IGiftApi;
import com.jiaai.guard.IGuardApi;
import com.jiaai.member.api.IMemberLevelApi;
import com.jiaai.system.api.ILivePermission;
import com.jiaai.util.RestResultGenerator;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

//import com.jiaai.member.api.IMemberLevelConfigApi;

/**
 * Created by Administrator on 2018\3\23 0023.
 */
@RequestMapping("/api/v1/app/common")
@RestController
public class CommonConteller {
    @Reference
    private IGiftApi giftApi;

    @Reference
    private ILivePermission livePermission;

    @Reference
    private IGuardApi guardApi;

    @Reference
    private IMemberLevelApi memberLevelApi;

    @RequestMapping("/livePermissions/{type}")
    public  Object getLivePermissions(@PathVariable("type") String type){
        return livePermission.findByType(type);
    }



    @RequestMapping("/system/loadAllResource")
    public  Object loadAllResource()throws ServerException {
        Map<String,Object> map=new HashedMap();
        map.put("memberLvs",memberLevelApi.getAllNotPage());
        map.put("gifts",giftApi.findByAll());
        return RestResultGenerator.genSuccessResult(map);
    }
}
